#-*- coding: big5 -*-
class BookComponent:
    def __init__(self,strComponentName='',strText=''):
        self.strComponentName=strComponentName
        self.strText=strText
    def countChar(self): pass

class Composite(BookComponent):
    def __init__(self,strComponentName='',strText=''):
        BookComponent.__init__(self,strComponentName,strText)
        self.lstBookComponent=[]
    def countChar(self):
        intTotalLength=0
        for bookComponent in self.lstBookComponent:
            intTotalLength+=bookComponent.countChar()
        return intTotalLength
    def isLeaf(self): return False
       
class Paragraph(BookComponent):
    def accept(self,visitor):
        visitor.visitParagraph(self)
    def countChar(self):
        return len(self.strText)
    def isLeaf(self): return True

class BulletItem(Paragraph):
    def accept(self,visitor):
        visitor.visitBulletItem(self)

class UnorderedList(Composite):
    def accept(self,visitor):
        visitor.visitUnorderedList(self)

class Book(Composite):
    def accept(self,visitor):
        visitor.visitBook(self)
    def __init__(self,strComponentName,strText):
        Composite.__init__(self,strComponentName,strText)
        self.strAuthor=''

class Section(Composite):
    def accept(self,visitor):
        visitor.visitSection(self)
    def __init__(self,strComponentName,strText):
        Composite.__init__(self,strComponentName,strText)
    def countChar(self):
        intTotalLength=0
        for bookComponent in self.lstBookComponent:
           intTotalLength+=bookComponent.countChar()
        return intTotalLength
          
class Chapter(Section):
    def accept(self,visitor):
        visitor.visitChapter(self)
